
package fei.zhou.service8082.business.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * 描述该类
 * 
 * @class: HelloController
 * @date 2021/8/22 15:54
 * @author <a href="mailto:zhoufei@smartdot.com">周飞</a>
 * @Verson 1.0 -2021/8/22 15:54
 * @see
 */
@RestController
@RequestMapping("zipkin")
public class HelloController {
    
    public static final String url = "http://localhost:8083/zipkin/service3";
    public static final String url2 = "http://localhost:8084/zipkin/service4";
    @Autowired
    OkHttpClient client;
    
    @GetMapping("/service2")
    public String service() throws Exception {
        System.out.println("-----调用service2-----");
        Request request1 = new Request.Builder().url(url).build();
        Request request2 = new Request.Builder().url(url2).build();
        
        Response response1 = client.newCall(request1).execute();
        Response response2 = client.newCall(request2).execute();
        return "service2【来自service3的信息:" + response1.body().string() +
                         ",来自service4的信息:"+ response2.body().string() + "】";

    }
}